// CWCheckbox.cpp : implementation file
//

#include "stdafx.h"
#include "assit.h"
#include "CWCheckbox.h"
#include "AssitTreeNode.h"


// CWCheckbox

IMPLEMENT_DYNAMIC(CWCheckbox, CButton)

CWCheckbox::CWCheckbox()
{

}

CWCheckbox::~CWCheckbox()
{
}


BEGIN_MESSAGE_MAP(CWCheckbox, CButton)
	ON_WM_ERASEBKGND()
	ON_WM_CTLCOLOR_REFLECT()
	ON_WM_CTLCOLOR()
	ON_CONTROL_REFLECT(BN_CLICKED, &CWCheckbox::OnBnClicked)
END_MESSAGE_MAP()



// CWCheckbox message handlers




BOOL CWCheckbox::OnEraseBkgnd(CDC* pDC)
{
	// TODO: Add your message handler code here and/or call default
	//CRect   m_rt;   
	//GetClientRect(&m_rt);   
	//CBrush   brush;   
	//brush.CreateSolidBrush(RGB(255,255,255));   
	//pDC->FillRect(&m_rt,&brush); 

	//pDC->SetBkMode(TRANSPARENT);

	return CButton::OnEraseBkgnd(pDC);
}


HBRUSH CWCheckbox::CtlColor(CDC* pDC, UINT nCtlColor)
{
	// TODO:  Change any attributes of the DC here
	HBRUSH hbr =  (HBRUSH) GetStockObject (WHITE_BRUSH) ;
	//pDC->SelectObject(hbr);
	// TODO:  Return a non-NULL brush if the parent's handler should not be called
	return hbr;
}


HBRUSH CWCheckbox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
	HBRUSH hbr = CButton::OnCtlColor(pDC, pWnd, nCtlColor);

	// TODO:  Change any attributes of the DC here

	// TODO:  Return a different brush if the default is not desired
	return hbr;
}


void CWCheckbox::OnBnClicked()
{
	// TODO: Add your control notification handler code here

	CWaiTreeNode* pTreeNode = (CWaiTreeNode*)GetParent();
	pTreeNode->setCheck(GetCheck() == BST_CHECKED? TRUE:FALSE, TRUE, TRUE);
}
